import { IResponse } from '@/types/data'
import { GoodsInfo } from '@/types/good'
import request from '@/utils/request'
import { defineStore } from 'pinia'

export default defineStore('goods', {
    state: () => ({
        info: {} as GoodsInfo,
    }),
    actions: {
        async getGoodsInfo(id: string) {
            const res = await request.get<IResponse<GoodsInfo>>('/goods', {
                params: {id}
            })
            this.info = res.data.result
            console.log('getGoodsInfo',res)
        },
        resetGoodsInfo() {
            this.info = {} as GoodsInfo
        }
    }
})